package cn.wolfcode.crm.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.CustomerTraceHistory;
import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.mapper.CustomerTraceHistoryMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ICustomerTraceHistoryService;
@Service
public class CustomerTraceHistoryImpl implements ICustomerTraceHistoryService{

	@Autowired
	private CustomerTraceHistoryMapper customerTraceHistoryMapper;

	@Override
	public void saveOrUpdate(CustomerTraceHistory entity) {
		if (entity.getId() == null) {
			//自动录入时间
			entity.setInputTime(new Date());
			System.err.println(entity.getCustomer().getId());
			customerTraceHistoryMapper.insert(entity);
		}else {
			customerTraceHistoryMapper.update(entity);
		}
		
	}

	@Override
	public CustomerTraceHistory get(Long id) {
		return customerTraceHistoryMapper.selectById(id);
	}

	@Override
	public PageInfo<CustomerTraceHistory> list(QueryObject qo) { 
		PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
		List<CustomerTraceHistory> list = customerTraceHistoryMapper.selectAll(qo);
		return new PageInfo<>(list);
	}

}
